home *** CD-ROM | disk | FTP | other *** search
/ Aminet 13 / Aminet 13 - August 1996.iso / Aminet / dev / e / energy.lha / Energy / Easy / SelectIcons.e < prev   
Text File  |  1996-05-18  |  4KB  |  132 lines

  1. /* SelectIcons.e
  2.  * Come realizzare l'effetto del rettangolo di selezione
  3.  * delle icone come sul Workbench
  4.  * Scritto da Marco Talamelli 03-11-95
  5.  */
  6.  
  7. MODULE     'exec/ports','intuition/intuition','intuition/screens','tools/macros'
  8.  
  9. PROC main( )
  10.  
  11. DEF    x:PTR TO INT,
  12.     y:PTR TO INT,
  13.     class,
  14.     code,
  15.     imsg:PTR TO intuimessage,
  16.     win:PTR TO window,
  17.     scr:PTR TO screen,
  18.        pattern = $ff00, 
  19.     newpat = $ff00,
  20.        done = TRUE,
  21.     first = TRUE,
  22.     rect[10]:ARRAY OF INT
  23.  
  24. rect:=[ 0, 0, 1, 0, 1, 1, 0, 1, 0, 0 ]:INT
  25.  
  26.    IF scr := LockPubScreen(NIL)
  27.  
  28.       IF win := OpenWindowTagList( NIL, [ WA_PUBSCREEN, scr,
  29.                        WA_TITLE,        'SelectIcons Demo del 03.11.95',
  30.                        WA_GADGETS,      NIL,
  31.                        WA_AUTOADJUST,   TRUE,
  32.                        WA_WIDTH,        scr.width,
  33.                        WA_INNERHEIGHT,  scr.height,
  34.                        WA_DRAGBAR,      TRUE,
  35.                        WA_DEPTHGADGET,  TRUE,
  36.                        WA_ACTIVATE,     TRUE,
  37.                        WA_CLOSEGADGET,  TRUE,
  38.                        WA_FLAGS,        WFLG_REPORTMOUSE,
  39.                        WA_IDCMP,       IDCMP_CLOSEWINDOW OR
  40.                                         IDCMP_MOUSEBUTTONS OR
  41.                                         IDCMP_MOUSEMOVE OR
  42.                                         IDCMP_INTUITICKS,
  43.                        NIL,         NIL])
  44.  
  45.    setdrpt( win.rport, pattern )
  46.    SetDrMd( win.rport, 2 )
  47.  
  48.    WHILE done
  49.       Wait(Shl(1, win.userport.sigbit))
  50.  
  51.       WHILE imsg := GetMsg( win.userport )
  52.          class := imsg.class
  53.          code := imsg.code
  54.          SELECT class
  55.             CASE  IDCMP_INTUITICKS
  56.                   IF first=FALSE
  57.                      Move( win.rport, rect[0], rect[1] )
  58.                      PolyDraw( win.rport, 5, rect )
  59.  
  60.                      newpat := Shr(pattern,4)
  61.                      newpat := newpat OR Shl(( pattern AND $000f ), 12)
  62.                      pattern := newpat
  63.                      setdrpt( win.rport, pattern )
  64.  
  65.                      Move( win.rport, rect[0], rect[1] )
  66.                      PolyDraw( win.rport, 5, rect )
  67.                      ENDIF
  68.  
  69.             CASE  IDCMP_CLOSEWINDOW
  70.                   done := FALSE
  71.  
  72.             CASE  IDCMP_MOUSEBUTTONS
  73.                   SELECT  code
  74.                      CASE  SELECTUP
  75.                            first := TRUE
  76.                            Move( win.rport, rect[0], rect[1] )
  77.                            PolyDraw( win.rport, 5, rect )
  78.  
  79.                      CASE  SELECTDOWN
  80.                            IF  first
  81.                               rect[0] := x
  82.                               rect[6] := x
  83.                               rect[8] := x
  84.                               rect[1] := y
  85.                               rect[3] := y
  86.                               rect[9] := y
  87.  
  88.                               rect[2] := x
  89.                               rect[4] := x
  90.                               rect[5] := y
  91.                               rect[7] := y
  92.  
  93.                               first := FALSE
  94.  
  95.                               Move( win.rport, rect[0], rect[1] )
  96.                               ENDIF
  97.                      ENDSELECT
  98.  
  99.             CASE  IDCMP_MOUSEMOVE
  100.                   IF first=FALSE
  101.                      rect[2] := x
  102.                      rect[4] := x
  103.                      rect[5] := y
  104.                      rect[7] := y
  105.  
  106.                      Move( win.rport, rect[0], rect[1] )
  107.                      PolyDraw( win.rport, 5, rect )
  108.  
  109.                      x := imsg.mousex
  110.                      y := imsg.mousey
  111.  
  112.                      rect[2] := x
  113.                      rect[4] := x
  114.                      rect[5] := y
  115.                      rect[7] := y
  116.  
  117.                      Move( win.rport, rect[0], rect[1] )
  118.                      PolyDraw( win.rport, 5, rect )
  119.                   ELSE
  120.                      x := imsg.mousex
  121.                      y := imsg.mousey
  122.                      ENDIF
  123.             ENDSELECT
  124.          ReplyMsg( imsg )
  125.          ENDWHILE
  126.       ENDWHILE
  127.       UnlockPubScreen( NIL, scr )
  128.          CloseWindow( win )
  129.          ENDIF
  130.       ENDIF
  131. ENDPROC
  132.